package com.niit.dao

import java.util.Properties

import com.niit.bean.AnswerWithRecommendations
import com.niit.utils.SparkUtil
import org.apache.spark.sql.Dataset

class EDUBatchDao {

  private val spark = SparkUtil.takeSpark()
  import spark.implicits._
  import org.apache.spark.sql.functions._

  //获取edu表中的数据
  def getEDUData():Dataset[AnswerWithRecommendations]={
    val props = new Properties()
    props.setProperty("user","root")
    props.setProperty("password","Niit@123")

    val answerData: Dataset[AnswerWithRecommendations] = spark.read.jdbc("jdbc:mysql://node1:3306/BD1?useUnicode=true&characterEncoding=utf8",
      "edu", props).as[AnswerWithRecommendations]
    answerData

  }

}
